package pt.ipbeja.estig.eda;

//http://rafaelsakurai.blogspot.pt/2008/06/bubble-sort-em-java.html
public class BubbleSort
{
   int[] array;
   
   /**
    * Bubble Sort Constructor
    * @param array Number List
    */
   public BubbleSort( int[] array )
   {
      this.array = array;
   }
   
   /**
    * Bubble Sort Method
    */
   public void sort()
   {
      for( int i = 0; i < this.array.length - 1; i++ )
      {
         for( int j = 0; j < this.array.length - 1 - i; j++ )
         {
            if ( this.array[ j ] > this.array[ j + 1] )
            {
               int temp = this.array[ j ];
               this.array[ j ] = this.array[ j + 1 ];
               this.array[ j + 1 ] = temp;
            }
         }
      }
   }
}